home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Commodore Free 26
/
Commodore_Free_Issue_26_2009_Commodore_Computer_Club.d64
/
in the beginning
< prev
next >
Wrap
Text File
|
2023-02-26
|
11KB
|
358 lines
u
In the Beginning 11
part one
--------------------
By Lord Ronin from Q-Link
Having gone through how we make more
than a one sprite active, there is a
bit more to it than we have covered
last session. We will move ahead to
some vague things for me, then back to
multiple sprites. As well as fixing
the problem of our sprite not going
all the way across the screen.
Down to line #12 from our programme.
The line Says poke 2042,13. Right we
know poke is put something into the
computer. 2042 is a location. Looking
back at that chart, the one that goes
from 2040 to 2047, for the 8 sprite
memory locations. We can see that 2042
is the number for sprite #2. That part
is pretty easy, I lose it at the next
part. That ,13 part. The manual says
"13th area of memory." and continues
with the information that a sprite
takes up 63 sections of memory. Said
just about that way. Yeah I get lost
here. OK it helps a little bit with
the following. As they talk about
doing all of that three series adding
up stuff to make the data for the
sprite. 21 rows, three series each row
is 63. Got that part figured out.
What's next is that each one of those
series. I mean the 128 64 32 16 8 4 2
1 series on each row is 1 byte of
computer memory. therefore each row is
3 bytes of computer memory. So an
entire sprite is 63 bytes of computer
memory. Impressive that we can do so
much with so little space.
line 20, we have a for and next loop,
In that we have 0-62, remember 0
starts so there is really 63 units.,
hmmm that is the same number of things
you put in those data statements. 63
for the amount of numbers inserted in
the data statement, 63 for the bytes
of memory used for a sprite. Here too
we have the read q part. Read is the
command to go look at the data. Going
out on a limb here in my
understanding. Q then would be a
variable for that information, as the
next part of the like poke 832+n,Q.
Fits as a 63 time around variable that
is read and poked into the memory of
the machine. Again the book says this
loop is poked into the 13th block of
memory. Starting at location 832.
Again I have no idea of this 13th
block and why or how they picked
location 832. Only that it works in
the lessons here.
line 40 we are pokeing v+4,x and at
line 50 we are poking v+5,x. That 4 is
the controller for sprite 2 in the X
co-ordinate. While the 5 is the same
for the same sprite save that it is
the Y coordinate. Doesn't make too
much sense by itself. Remember though
we have line 30 which is the for X = 0
to 200. Add that value of X to both
the +4 and the +5. Then there will be
a replacement across and down the
screen. Making the diagonal movement.
Trick here is that it is moving so
fast, since the data is being read
fast and the computer runs fast. You
see the balloon float diagonally
across the screen, this is the same
sort of trick used for years to make
animation. Show, move, show again,
Just do it so fast the eye doesn't see
the changes.
Well there is a note to look at the
back of the book for the list of the
registers. All 46 are listed with some
very minor explanations to them, that
isn't a part of this series but
personally maybe that is where some of
the raster stuff is done and where the
controls for a light pen can be
accessed. As they are listed in that
area as are several sprite things, and
yes that 23 and 29 part from last
instalment is right for what they do
with a sprite.
So each sprite has its own 2 sets of
memory sections to make it and to move
it on the screen. Now they want you to
try the following. Add this line to
the programme...
25 pOv+23,4:pOv+29,4: rem expand
Run the program and your balloon just
got taller and wider by around twice
as much. Right that 23 makes it taller
and the 29 makes it wider, ok and the
4 is still playing around with the 2nd
sprite. Play a bit with just pokeing
one or the other. But leave one of
them out. See what your balloon looks
like now. <groans are accepted at the
sight> Note too that it still starts
from the same section of the screen.
Next they want you to modify some
lines...
11 pOv+21,12
12 pO2042,13:pO2043,13
30 forx=1to190
45 pOv+6,x
55 pOv+7,190-x
The extra lines above did some
changes, like line 45 and line 55, you
note that line 11 changed the ,4 to a
,12. As we talked about earlier this
will mean that sprite 2 and sprite 3
are now activated. Line 12 adds a new
poke command, and that is 2043,13.
Looking back on the charts, the one
for the sprite locations. 2043 is the
number for sprite #3.
Off of that rant for a moment and
back to line 30 there is a change in
the writing of the for part. Instead
of 0 to 200 it is now 1 to 190. Not
sure why this is done. But it works on
the screen.
At line 45 we poke in v+6,x. Line 55
we poke in v+7,190-x. That 6 & 7 must
be or the new sprite. But we have a
reverse of something here. 190-x is
gonna make it do what?
Run the newly modified program and
lets see what happens, what I had was
a cyan big balloon going as it had
before. now a little purple one is
going in sort of the opposite
direction, bottom left corner of the
screen to the top right. OK we have
two sprites moving on the screen at
two sizes in two directions. Time to
complicate things even more.
11 pO v+21,28
12 pO2042,13:pO2043,13:pO2044,13
25 pOv+23,12:pOv+29,12
48 pOv+8,x
58 pOv+9,100
Before you run this one, I'll lay odds
that you can see we have added another
sprite to the mix. You should see that
in line 11 with the higher number, you
will also see that in line 12 there is
a third poke for another sprite
location. This is going to be a
balloon because of that ,13. This is
obtaining the information from the
same location as the other two
sprites. At line 25 we do something a
little different, we poke the
expansion codes into two of the
balloon sprites. Seeing that it is the
same number of 12,that means it is the
4 and the 8 values, or sprites 2 & 3.
48 is a similar line, to what we have
seen before, this line controls the
horizontal direction. Line 58 is close
to what we have seen before,
understanding that the 9 will deal
with this sprites vertical movement,
hmm no variable or negative number
here, What happens in this program?
Give it a run, you should see the
balloon as before on the screen,
except that both of those two balloons
are now bigger. The third sprite, is
also another balloon and is coloured
green, this sprite went directly
across the screen as far as it could.
That may be what that line 58 is
supposed to make it do?
"Additional Notes on Sprites" is the
next part of the book, there are
questions, not all of them raised are
covered above.
Starting off is changing the colour
of the sprite, repeating the command
of v=53248 as the way to set the
video. We are told that to change the
colour of our first sprite, or "sprite
1" to type in pokev+40,13 to make the
sprite a light green, That 40 is the
register code, for sprite #1. The only
problem is, that we haven't turned on
sprite #1 in our program. Next part of
the ,13 is the light green colour, so
for your experiments, a refresher.
39-46 is for sprite colour 0-7.
Pokeing v+40 is the register number
for the sprite #1. If that was a poke
v+39 it would be for sprite #0. 41 for
sprite #2. 42 = sprite #3, 43 = sprite
# 4, 44 = sprite #5, 45 = sprite #6
and finally 46 = sprite #7.
There are charts that will tell you
the number between 0 and 15 for the
colours, the easiest way to remember
that in this part of programming. We
start at the colours listed on the
keys, though not all models have the
second set of colours listed. Black is
1 on the keys so remember control and
1 to change to black for text and the
cursor, as well as in print
statements? Well here we start with 1
on the keys, but in programming we
start at 0. So Black = 0. Light Grey
is the 16th colour. Since we started
at Black as 0 then Light Grey, the
last colour number would be 15, simply
stated; just subtract one from the key
readings, so the white key is number
2, this would be 1 in the code list,
Cyan is 4 on the key and therefore 3
in the code. Yellow is 8 on the key,
so it is 7 in the code.
Next they tell us that we may have
noticed that the sprite didn't go all
the way to the way to the right hand
side of the screen. Yeah we did see
that one, the reason for this is that
our value for that specific register
is the maximum that it can be, 255.
While the screen is 320, they say dots
for their illustration of a 320 dot
wide screen and 255 dots for the
direction.
We know it can move across the
screen, as we have seen it in
programmes. How is it done then? Back
to that registers and description
chart; register 16 is the Most
Significant Bit <MSB> and it appears
that it is for the X or horizontal
coordinate. What we do is poke the
value of the sprite into the memory at
this position of 16, doing that for
sprite #2, it would read pokev+16,4.
That will take it past the 255
location on the screen and move it
from 256 to the 320 location.
We will have the programme in just a
moment, What I want to present at this
point is the fact that there are only
64 spaces on the horizontal that the
sprite needs to move all the way
across the screen. Keeping that in
mind, lets do the programme. First off
this program is only for one balloon.
Pretty much keep just the DATA
statements from your previous balloon
work, Kill off the other lines and
then type in the following.
10 v=53248:pOv+21,4:pO2042,13
20 forn=0to62:readq:poke832+n,q:next
25 pOv+5,100
30 forx=0to255
40 pOv+4,x
50 next
60 pOv+16,4
70 forx=0to63
80 pOv+4,x
90 next
100 pOv+16,0
110 goto30
Line 10 is a tad bit different, sure
we have the turn on the chip with the
variable v, then followed by the
turning on the sprite and the sprite
being the 2nd one <value of 4
remember>. Next we poke into the
sprite our data values. What is new
then? Well you have used all those
commands on one line. Using that :
symbol to separate different commands
on one line, rather than write a mess
of separate code lines.
line or 20. Has that part that reads
all 63 parts of the sprite, doing that
0 to 62 bit for Q with the READ
command. Line 25 has the "Y"
coordinate for the sprite, here we see
a 100 rather than the previous "X".
Line 30 has the "X" But see that it is
0-255, line 40 we have the semi
familiar poke for the second sprite
and the horizontal coordinate. Note
that it is "X" and that is generated
in line 30 for 0 to 255.
Pretty much what we have done
already, line 50 is a next and must be
for that for in line 30. line 60 we
have something new, pokev+16,4. That
one is for making the MSB or Most
Significant Bit trip. Poked that into
the v variable and that, 4 is the
value for the second sprite, the one
that has been working for us through
out the prg.
Line 70 is the rest of what we read
about just a little bit ago, Here we
have for x = 0 to 63. That is the next
64 spaces on the screen to make it go
all the way to the right hand side of
the screen.
CONTINUED IN PART 2